import os
import sys
import getopt
import SCons

helpString = """
Usage:
        scons [target] [compile options]
Targets:
        Default:                Build release binaries and libraries
        test:                   Build test binaries and required libraries
        binaries:               Build release binaries and required libraries
	libraries:              Build all libraries
	doc: 			Generates the all documentation
        install:                Install release binaries, includes, and libraries
        isntall-test:           Install test binaries

Compile Options:
        optimized:              Set to 1 to compile with optimization. Default 0.
        debug:                  Set to 1 to compile with debug. Default 0.
        CC:                     Set to the compiler to use for C source code.
        CXX:                    Set to the compiler to use for C++ source code.
        CCFLAGS:                Set to additional flags passed to the C compiler.
        CXXFLAGS:               Set to additional flags passed to the C++ compiler.
"""

Help(helpString)


env = Environment() # Standard environment
debugEnv = Environment(CCFLAGS = ['-pg --fprofile-arcs --ftest-coverage -g2'], LIBPATH=['/usr/lib'])
optEnv = Environment(CCFLAGS = ['-O2'])



if 'doc' in COMMAND_LINE_TARGETS:
	os.system("doxygen")

if 'optimized' in BUILD_TARGETS:
	env = debugEnv
	print "Environment: Optmized"
elif 'debug' in BUILD_TARGETS: 
	env = optEnv
	print "Environment: Debug"
else:
	env = Environment()

Export('env')
SConscript(['src/SConscript'])













#os.system("lcov --directory src --zerocounters")
#os.system("valgrind -q --xml=yes src/sparwe --test")
#os.system("lcov --directory src --capture --output-file lcov.info")
#os.system("genhtml lcov.info")
#os.system("gprof gmon.out > profile.out")

